package com.es.filter; /**
 * 描述:
 * es-servlet-
 *
 * @author Derek
 * 创建时间：2022-04-22 11:35
 */

import javax.servlet.*;
import javax.servlet.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebFilter(filterName = "EncodingFilter", urlPatterns = "/*")
public class EncodingFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
        HttpServletRequest req = (HttpServletRequest) request;
        System.out.println(req.getRequestURI());
        request.setCharacterEncoding("utf-8");
        chain.doFilter(request, response);
    }
}
